﻿/**
//  CameraEventListener.cs
//  Marquee Moment
//  Copyright 2011 Systematix Technocrates. All rights reserved.
**/
using System;
using EDSDKLib;
using MarqueeMoment.Forms;

namespace MarqueeMoment.CameraController.Camera
{
    public class CameraEventListener
    {

        public static uint handleObjectEvent(uint inEvent, IntPtr inRef, IntPtr inContext)
        {

            uint rtn = 0;

            switch (inEvent)
            {
                case EDSDK.ObjectEvent_DirItemRequestTransfer:
                    frmTakePhoto.controller.actionPerformed("download", inRef);
                    //Call Timer method here
                    frmTakePhoto.OnPictureDownloaded();
                    
                    break;
                default:
                    ////Release unnecessary objects.
                    if ((inRef == null) == false)
                    {
                        EDSDK.EdsRelease(inRef);
                    }

                    break;
            }

            rtn = Convert.ToUInt16(EDSDK.EDS_ERR_OK);
            return rtn;

        }


        public static uint handlePropertyEvent(uint inEvent, uint inPropertyID, uint inParam, IntPtr inContext)
        {

            uint rtn = 0;

            switch (inEvent)
            {
                case EDSDK.PropertyEvent_PropertyChanged:
                    frmTakePhoto.controller.actionPerformed("get", inPropertyID, 0);//frmTakePhoto.controller.actionPerformed("get", inPropertyID); December 23_2011
                    break;
                case EDSDK.PropertyEvent_PropertyDescChanged:
                    frmTakePhoto.controller.actionPerformed("getlist", inPropertyID, 0);//frmTakePhoto.controller.actionPerformed("getlist", inPropertyID); December 23_2011
                    break;
            }


            rtn = Convert.ToUInt16(EDSDK.EDS_ERR_OK);
            return rtn;

        }


        public static uint handleStateEvent(uint inEvent, uint inParam, IntPtr inContext)
        {

            uint rtn = 0;

            switch (inEvent)
            {
                case EDSDK.StateEvent_Shutdown:
                    frmTakePhoto.controller.actionPerformed("clse");
                    break;
                case EDSDK.StateEvent_JobStatusChanged:
                    frmTakePhoto.UpdateSpinner(true);
                    break;
            }


            rtn = Convert.ToUInt16(EDSDK.EDS_ERR_OK);
            return rtn;

        }


    }
}
